package com.juyu.miliao.api.service;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author jh
 * 2018/8/3
 */
@Component
public class UpdateHomeVideoService {

    @Resource
    private AmqpTemplate amqpTemplate;

    /**
     * 推送video id更新首页视频
     *
     * @param videoId videoId
     */
    public void publishByVideoId(Long videoId) {
        if (videoId != null && videoId > 0L) {
            amqpTemplate.convertAndSend("home.video.id", videoId.toString());
        }
    }

    /**
     * 推送user id更新首页视频
     *
     * @param userId userId
     */
    public void publishByUserId(Long userId) {
        if (userId != null && userId > 0L) {
            amqpTemplate.convertAndSend("home.user.id", userId.toString());
        }
    }
}
